package net.sf.midollo.net.cgitunnel.client;

import java.io.IOException;
import java.io.OutputStream;

public class CGITunnelClientOutputStream extends OutputStream {

	protected final byte[] singleByteBuffer;
	protected final CGITunnelClient client;

	public CGITunnelClientOutputStream(CGITunnelClient client) {
		this.singleByteBuffer = new byte[1];
		this.client = client;
	}

	public void write(int b) throws IOException {
		this.singleByteBuffer[0] = (byte)b;
		write(this.singleByteBuffer, 0, 1);
	}

	public void write(byte b[]) throws IOException {
		write(b, 0, b.length);
	}

	public void write(byte b[], int off, int len) throws IOException {
		this.client.requestCmdWrite(b, off, len);
	}

	public void flush() throws IOException {
	}

	public void close() throws IOException {
		flush();
	}
}
